Skip to content

Commit

Permalink
Spec Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-s19 committed Dec 28, 2023
1 parent d386da4 commit 21e94e5
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions src/api/fusionauth/query-generator/query-generator.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('QueryGeneratorService', () => {
const applicationId = "1234-1234-1234-1234";
const applicationIds = ["1234-1234-1234-1234", "1234-1234-1234-1234"];
const queryString = "test";

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [QueryGeneratorService],
Expand Down Expand Up @@ -49,38 +49,33 @@ describe('QueryGeneratorService', () => {
})

it('should create queryUsersByApplicationIdAndQueryString query', () => {
const result = JSON.stringify({
bool: {
must: [
{
bool: {
must: [
[
{
nested: {
path: "registrations",
query: {
bool: {
should: service.createMatchTags(applicationIds)
}
}
}
}
]
]
}
},
{
query_string: {
query: queryString

const result: any = {
"bool": {
"must": [{
"nested": {
"path": "registrations",
"query": {
"bool": {
"must": service.createMatchTags(applicationIds)
}
}
}
]
}]
}
})
}

if (queryString) {
result.bool.must.push(
{
"query_string": {
"query": queryString
}
})
}

jest.spyOn(service, 'queryUsersByApplicationIdAndQueryString');
expect(service.queryUsersByApplicationIdAndQueryString(applicationIds, queryString)).toBe(result);
expect(service.queryUsersByApplicationIdAndQueryString(applicationIds, queryString)).toBe(JSON.stringify(result));

})
});

0 comments on commit 21e94e5

Please sign in to comment.