This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate to Node.js test runner
Closes #592
- Loading branch information
1 parent
534fdd6
commit 4d4968d
Showing
15 changed files
with
4,373 additions
and
8,876 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged && npm test && npx tsc | ||
npx lint-staged | ||
npm test | ||
npx tsc |
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
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
32 changes: 19 additions & 13 deletions
32
feature-runner/steps/device/matchDeviceBoundTopic.spec.ts
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 |
---|---|---|
@@ -1,32 +1,38 @@ | ||
import { matchDeviceBoundTopic } from './matchDeviceBoundTopic.js' | ||
import { describe, it } from 'node:test' | ||
import assert from 'node:assert/strict' | ||
|
||
describe('matchTopic', () => { | ||
it('should match a simple topic', () => | ||
expect( | ||
void describe('matchTopic', () => { | ||
void it('should match a simple topic', () => | ||
assert.equal( | ||
matchDeviceBoundTopic( | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound', | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound', | ||
), | ||
).toEqual(true)) | ||
it('should match topic with a property bag', () => | ||
expect( | ||
true, | ||
)) | ||
void it('should match topic with a property bag', () => | ||
assert.equal( | ||
matchDeviceBoundTopic( | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound/pgps=result', | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound/%24.to=%2Fdevices%2F49dd7d86-e547-4a4d-8f0f-f4b09591838c%2Fmessages%2Fdevicebound&pgps=result&%24.ct=application%2Fjson&%24.ce=utf-8', | ||
), | ||
).toEqual(true)) | ||
it('should not match topic with a property bag thats not contained', () => | ||
expect( | ||
true, | ||
)) | ||
void it('should not match topic with a property bag thats not contained', () => | ||
assert.equal( | ||
matchDeviceBoundTopic( | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound/agps=result', | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound/%24.to=%2Fdevices%2F49dd7d86-e547-4a4d-8f0f-f4b09591838c%2Fmessages%2Fdevicebound&pgps=result&%24.ct=application%2Fjson&%24.ce=utf-8', | ||
), | ||
).toEqual(false)) | ||
it('should match a topic regardless of property bag', () => | ||
expect( | ||
false, | ||
)) | ||
void it('should match a topic regardless of property bag', () => | ||
assert.equal( | ||
matchDeviceBoundTopic( | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound', | ||
'devices/49dd7d86-e547-4a4d-8f0f-f4b09591838c/messages/devicebound/%24.to=%2Fdevices%2F49dd7d86-e547-4a4d-8f0f-f4b09591838c%2Fmessages%2Fdevicebound&pgps=result&%24.ct=application%2Fjson&%24.ce=utf-8', | ||
), | ||
).toEqual(true)) | ||
true, | ||
)) | ||
}) |
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
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { lowerCaseRecord } from './lowerCaseRecord.js' | ||
import { describe, it } from 'node:test' | ||
import assert from 'node:assert/strict' | ||
|
||
describe('lowerCaseRecord', () => { | ||
it('should lower-case all keys', () => | ||
expect( | ||
void describe('lowerCaseRecord', () => { | ||
void it('should lower-case all keys', () => | ||
assert.deepEqual( | ||
lowerCaseRecord({ | ||
Foo: 'Bar', // will be overwritten by the next key | ||
foo: 'bar', | ||
}), | ||
).toMatchObject({ foo: 'bar' })) | ||
{ foo: 'bar' }, | ||
)) | ||
}) |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { parseConnectionString } from './parseConnectionString.js' | ||
|
||
describe('parseConnectionString', () => { | ||
it('should parse a connection string', () => { | ||
expect( | ||
import { describe, it } from 'node:test' | ||
import assert from 'node:assert/strict' | ||
void describe('parseConnectionString', () => { | ||
void it('should parse a connection string', () => { | ||
assert.deepEqual( | ||
parseConnectionString( | ||
'AccountEndpoint=https://xxxx.documents.azure.com:443/;AccountKey=oKHTAxxx92GKkq3CDzeCd1WYnVslfIUaQqOa7Xw==;', | ||
), | ||
).toEqual({ | ||
AccountEndpoint: 'https://xxxx.documents.azure.com:443/', | ||
AccountKey: 'oKHTAxxx92GKkq3CDzeCd1WYnVslfIUaQqOa7Xw==', | ||
}) | ||
{ | ||
AccountEndpoint: 'https://xxxx.documents.azure.com:443/', | ||
AccountKey: 'oKHTAxxx92GKkq3CDzeCd1WYnVslfIUaQqOa7Xw==', | ||
}, | ||
) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { sortQueryString } from './sortQueryString.js' | ||
|
||
describe('sortQueryString', () => { | ||
it('should sort the query part of a mock URL', () => | ||
expect( | ||
import { describe, it } from 'node:test' | ||
import assert from 'node:assert' | ||
void describe('sortQueryString', () => { | ||
void it('should sort the query part of a mock URL', () => | ||
assert.equal( | ||
sortQueryString( | ||
'api.nrfcloud.com/v1/location/agps?eci=73393515&tac=132&requestType=custom&mcc=397&mnc=73&customTypes=2', | ||
), | ||
).toEqual( | ||
'api.nrfcloud.com/v1/location/agps?customTypes=2&eci=73393515&mcc=397&mnc=73&requestType=custom&tac=132', | ||
)) | ||
}) |
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { splitMockResponse } from './splitMockResponse.js' | ||
|
||
describe('split mock response', () => { | ||
it('should parse headers and body', () => | ||
expect( | ||
import { describe, it } from 'node:test' | ||
import assert from 'node:assert' | ||
void describe('split mock response', () => { | ||
void it('should parse headers and body', () => | ||
assert.deepEqual( | ||
splitMockResponse(`Content-Type: application/octet-stream | ||
(binary A-GNSS data) other types`), | ||
).toMatchObject({ | ||
headers: { | ||
'Content-Type': 'application/octet-stream', | ||
{ | ||
headers: { | ||
'Content-Type': 'application/octet-stream', | ||
}, | ||
body: '(binary A-GNSS data) other types', | ||
}, | ||
body: '(binary A-GNSS data) other types', | ||
})) | ||
)) | ||
}) |
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
Oops, something went wrong.