it('should GET /news/item/:id', async () => { await app.httpRequest() .get('/news/item/1') // just a example, use regex to test part of dom string, but should be strong characteristic .expect(/\/news\/item\/1/) .expect(200); });
it('should GET /news/user/:id', async () => { await app.httpRequest() .get('/news/user/activatedgeek') // just a example, use regex to test part of dom string, but should be strong characteristic .expect(/<span class="label">user:<\/span> activatedgeek/) .expect(200); });
it('should GET /', async () => { const result = await app .httpRequest() .get('/') .expect(200); assert(result.text === 'hi, egg'); });
it('should work', async () => { await app .httpRequest() .get('/') .expect('hi, egg') .expect(200); });
it('should GET /news', async () => { const result = await app.httpRequest().get('/news').expect(200); const $ = cheerio.load(result.text); const listItem = $('.news-view .item'); assert(listItem.length === app.config.news.pageSize); });
before(() => { ctx = app.mockContext(); });
beforeEach(() => { app.mockCsrf(); });
it('should visit / without error', () => { return app .httpRequest() .get('/') .expect(200); });
before(async () => { ctx = app.mockContext(); });
before(async () => { await app.ready(); ctx = app.mockContext({}) as Context; });