|
| 1 | +import test from 'ava'; |
| 2 | +import sinon from 'sinon'; |
1 | 3 | import Alpr from './../src/index';
|
2 | 4 | import data from './aws-data-file.json';
|
3 | 5 |
|
4 | 6 | data.callback = () => {};
|
5 |
| -// eslint-disable-next-line |
6 |
| -import test from 'ava'; |
7 | 7 |
|
8 | 8 | const alprGlobal = new Alpr(data);
|
| 9 | +const sandbox = sinon.sandbox; |
| 10 | + |
| 11 | +test.afterEach(() => { |
| 12 | + sandbox.restore(); |
| 13 | +}); |
9 | 14 |
|
10 | 15 | test('Route Matching > matches path strings and resource strings', (t) => {
|
11 | 16 | const result = alprGlobal.routeMatcher({
|
@@ -270,3 +275,19 @@ test('String Matching > will return false when no params are provided', (t) => {
|
270 | 275 | // Just for default params
|
271 | 276 | t.is(Alpr.inArrayOrIsString(), false);
|
272 | 277 | });
|
| 278 | + |
| 279 | +test('Logging request ids > Logs out the ids when they are available', (t) => { |
| 280 | + const spy = sandbox.spy(console, 'log'); |
| 281 | + |
| 282 | + alprGlobal.logRequestIds(); |
| 283 | + const consoleLog = spy.getCall(0).args[0]; |
| 284 | + t.true(consoleLog.includes(data.event.requestContext.requestId)); |
| 285 | + t.true(consoleLog.includes(data.context.awsRequestId)); |
| 286 | +}); |
| 287 | + |
| 288 | +test('Logging request ids > Does not log out the ids when they are not available', (t) => { |
| 289 | + const alprLocal = new Alpr({ callback: () => {} }); |
| 290 | + alprLocal.logRequestIds(); |
| 291 | + const spy = sandbox.spy(console, 'log'); |
| 292 | + t.false(spy.calledOnce); |
| 293 | +}); |
0 commit comments