Skip to content

Commit

Permalink
change find operator test name
Browse files Browse the repository at this point in the history
  • Loading branch information
generalpiston committed Jan 11, 2022
1 parent dc8cbaa commit d6567cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 26 additions & 23 deletions test/find-operator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Connection, In, Not, IsNull, Equal, Like, LessThan } from "typeorm";
import { getConnection } from "./utils";
import TransformerOptionsEntity3 from "./entities/TransformerOptionsEntity3";

describe("Column Options - Data Mapper", function () {
describe("Find operator", function () {
let connection: Connection;

this.timeout(10000);
Expand All @@ -21,41 +21,41 @@ describe("Column Options - Data Mapper", function () {
// Where in
const whereIn = await repo.find({
where: {
secret: In([secret1, secret2])
}
secret: In([secret1, secret2]),
},
});
expect(whereIn.length).to.equal(2);
expect(whereIn[0].secret).to.equal(secret1);
expect(whereIn[1].secret).to.equal(secret2);
// Where not
const whereNot = await repo.find({
where: {
secret: Not(secret2)
}
secret: Not(secret2),
},
});
expect(whereNot.length).to.equal(1);
expect(whereNot[0].secret).to.equal(secret1);
// Where equal
const whereEqual = await repo.find({
where: {
secret: Equal(secret1)
}
secret: Equal(secret1),
},
});
expect(whereEqual.length).to.equal(1);
expect(whereEqual[0].secret).to.equal(secret1);
// Where not in
const whereNotIn = await repo.find({
where: {
secret: Not(In([secret2]))
}
secret: Not(In([secret2])),
},
});
expect(whereNotIn.length).to.equal(1);
expect(whereNotIn[0].secret).to.equal(secret1);
// Where IsNull
const whereIsNull = await repo.find({
where: {
secret: IsNull()
}
secret: IsNull(),
},
});
expect(whereIsNull.length).to.equal(0);
} finally {
Expand All @@ -70,20 +70,23 @@ describe("Column Options - Data Mapper", function () {
const secret2 = "test4";
await repo.save([{ secret: secret1 }, { secret: secret2 }]);
// Can't use FindOperator except supported ones
for (const notSupportedOperator of [
LessThan(secret1),
Like(secret1)]) {
await repo.find({
for (const notSupportedOperator of [LessThan(secret1), Like(secret1)]) {
await repo
.find({
where: {
secret: notSupportedOperator
secret: notSupportedOperator,
},
})
.then(
() => {
throw new Error("Never resolved");
},
(reason) => {
expect(reason.message).to.equal(
'Only "Equal","In", "Not", and "IsNull" are supported for FindOperator'
);
}
}).then( () => {
throw new Error("Never resolved")
}, (reason) => {
expect(reason.message).to.equal(
'Only "Equal","In", "Not", and "IsNull" are supported for FindOperator'
)
});
);
}
} finally {
await repo.clear();
Expand Down

0 comments on commit d6567cc

Please sign in to comment.