-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unit test edit): unit test edit
unit test edit
- Loading branch information
Showing
2 changed files
with
34 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as nock from 'nock' | ||
|
||
import { API_CONFIG } from '../src/config/constants' | ||
import { Devices } from '../src/modules/devices' | ||
|
||
describe('Devices Test', () => { | ||
it('should be a class', () => { | ||
const devices = new Devices({} as any) | ||
expect(devices instanceof Devices).toBeTruthy() | ||
}) | ||
|
||
describe('getDeviceInfo() call', () => { | ||
it('should return device obj', async () => { | ||
nock(API_CONFIG.baseURL) | ||
.get(`/devices/9E1F98`) | ||
.reply(200) | ||
const devices = new Devices({} as any) | ||
const result = await devices.getDeviceInfo('9E1F98') | ||
expect(result).toMatchSnapshot() | ||
}) | ||
|
||
it('should return error', async () => { | ||
const devices = new Devices({} as any) | ||
try { | ||
nock(API_CONFIG.baseURL) | ||
.get(`/devices/9E1F98`) | ||
.reply(404) | ||
await devices.getDeviceInfo('9E1F98') | ||
} catch (error) { | ||
expect(error).toMatchSnapshot() | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters