Skip to content

Commit c37b3dd

Browse files
authored
chore: add tests for mime types (#260)
1 parent da4cfb0 commit c37b3dd

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

tests/main.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ describe('#run', () => {
9090
path.join(this.githubWorkspace, 'testdata', 'test2.txt'),
9191
path.join(this.githubWorkspace, 'testdata', 'test1.txt'),
9292
path.join(this.githubWorkspace, 'testdata', 'test.json'),
93+
path.join(this.githubWorkspace, 'testdata', 'test.js'),
94+
path.join(this.githubWorkspace, 'testdata', 'test.css'),
9395
path.join(this.githubWorkspace, 'testdata', 'nested1', 'test1.txt'),
9496
path.join(this.githubWorkspace, 'testdata', 'nested1', 'nested2', 'test3.txt'),
9597
]);
@@ -131,6 +133,8 @@ describe('#run', () => {
131133
path.join(this.githubWorkspace, 'testdata', '🚀'),
132134
path.join(this.githubWorkspace, 'testdata', 'testfile'),
133135
path.join(this.githubWorkspace, 'testdata', 'test.json'),
136+
path.join(this.githubWorkspace, 'testdata', 'test.js'),
137+
path.join(this.githubWorkspace, 'testdata', 'test.css'),
134138
]);
135139

136140
// Check arguments

tests/testdata/test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
display: none;
3+
}

tests/testdata/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(() => {
2+
alert('hi');
3+
})();

tests/upload.int.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,31 @@ describe('integration', () => {
146146
expect(list).to.eql(['test1.txt']);
147147
});
148148

149+
it('uploads files with the correct mime type', async function () {
150+
const client = new Client({ projectID: projectID });
151+
await client.upload({
152+
root: './tests/testdata',
153+
files: ['test.css', 'test.js', 'test.json', 'test1.txt'],
154+
destination: this.testBucket,
155+
});
156+
157+
const list = await getFilesInBucket(this.storage, this.testBucket);
158+
const names = list.map((file) => file.name);
159+
expect(names).to.eql(['test.css', 'test.js', 'test.json', 'test1.txt']);
160+
161+
const css = list[0];
162+
expect(css?.metadata.contentType).to.eql('text/css');
163+
164+
const js = list[1];
165+
expect(js?.metadata.contentType).to.eql('application/javascript');
166+
167+
const json = list[2];
168+
expect(json?.metadata.contentType).to.eql('application/json');
169+
170+
const txt = list[3];
171+
expect(txt?.metadata.contentType).to.eql('text/plain');
172+
});
173+
149174
it('uploads a single file with prefix', async function () {
150175
const client = new Client({ projectID: projectID });
151176
await client.upload({

0 commit comments

Comments
 (0)