Skip to content

Commit

Permalink
Makes tests run on github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Aug 8, 2023
1 parent aed6f95 commit 9eeec48
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Unit Tests

on:
push:
branches: [ "master" ]
paths:
- "**.ts"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- ".github/workflows/tests.yml"
pull_request:
branches: [ "master" ]
paths:
- "**.ts"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- ".github/workflows/tests.yml"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- run: npm ci
- run: npm run test
17 changes: 9 additions & 8 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,30 @@ describe('Worker', () => {
await worker.stop();
});

it('should return 200 response with a text opengraph tag',async () => {
it('should return 200 response with a text opengraph tag', async () => {
const req = new Request(
'https://fxtumblr.suckerberg.workers.dev/engineering/690135035533230080',
'https://txtumblr.suckerberg.workers.dev/engineering/690135035533230080',
{ method: 'GET' }
);
const resp = await worker.fetch(req.url);
expect(resp.status).toBe(200);


const text = await resp.text();
expect(text).toContain(`<meta property="og:description" content="Making GIFs load faster`)
})
expect(text).toContain('<meta name="description" content="Tags: #tumblr update');
});

it('should return 200 response with an image opengraph tag', async () => {
const req = new Request(
'https://fxtumblr.suckerberg.workers.dev/engineering/713599421825351680',
'https://txtumblr.suckerberg.workers.dev/engineering/713599421825351680',
{ method: 'GET' }
);
const resp = await worker.fetch(req.url);
expect(resp.status).toBe(200);


const text = await resp.text();
expect(text).toContain(`<meta property="og:image" content="https://64.media.tumblr.com/0807dffbcf1e9db8a3ddf31b4f026c39/dec349afc8bbeb99-9a/s2048x3072/a10138f06f43173037f613167f32acc41495996c.png" />`)
expect(text).toContain(
'<meta property="og:image" content="https://64.media.tumblr.com/0807dffbcf1e9db8a3ddf31b4f026c39/dec349afc8bbeb99-9a/s2048x3072/a10138f06f43173037f613167f32acc41495996c.png" />'
);
expect(text).toContain('<meta name="twitter:card" content="summary_large_image">');
});
});

0 comments on commit 9eeec48

Please sign in to comment.