Skip to content

Commit

Permalink
fix: Avoid meaningless replacing by octet-stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Oct 22, 2021
1 parent 71568fe commit a7157c5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/integration/Conversion.test.ts
Expand Up @@ -24,6 +24,45 @@ describe('Representation conversion', (): void => {
await app.stop();
});

describe('a Turtle document', (): void => {
const turtleUrl = `${baseUrl}turtle`;
const turtleBody = '# Test';

beforeAll(async(): Promise<void> => {
const res = await fetch(turtleUrl, {
method: 'PUT',
headers: { 'content-type': 'text/turtle' },
body: turtleBody,
});
assert.equal(res.status, 201);
});

it('is sent as text/turtle when no preference is given.', async(): Promise<void> => {
const res = await fetch(turtleUrl);
expect(res.status).toBe(200);
expect(res.headers.get('Content-Type')).toBe('text/turtle');
expect(await res.text()).toBe(turtleBody);
});

it('is sent as text/turtle when accepting */*.', async(): Promise<void> => {
const res = await fetch(turtleUrl, {
headers: { accept: '*/*' },
});
expect(res.status).toBe(200);
expect(res.headers.get('Content-Type')).toBe('text/turtle');
expect(await res.text()).toBe(turtleBody);
});

it('can be sent as application/octet-stream if that is the only option.', async(): Promise<void> => {
const res = await fetch(turtleUrl, {
headers: { accept: 'application/octet-stream' },
});
expect(res.status).toBe(200);
expect(res.headers.get('Content-Type')).toBe('application/octet-stream');
expect(await res.text()).toBe(turtleBody);
});
});

describe('a Markdown document', (): void => {
const markdownUrl = `${baseUrl}document`;
const markdownBody = '# Test';
Expand Down

0 comments on commit a7157c5

Please sign in to comment.