Skip to content

Commit

Permalink
test: verify that storing strings with characters that are too long f…
Browse files Browse the repository at this point in the history
…or var/char throws

ensure that we will fail loudly when an attempt is made to store a string that cannot be
converted to the underlying type because it has too-long characters

Tests typeorm#7933
  • Loading branch information
Ceshion committed Jul 19, 2021
1 parent a32b2d9 commit 8683211
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/github-issues/7932/issue-7932.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ describe("github issues > #7932 non-ascii characters assigned to var/char colum
expect(savedEntity?.fixedLengthContent).to.be.equal(entity.fixedLengthContent);
})));

it("should throw an error if characters in a string are too long to store", () => Promise.all(connections.map(async connection => {
const repo = connection.getRepository(Example);

const entity = new Example();
entity.content = '💖';
entity.fixedLengthContent = '🏍';

expect(repo.save(entity)).itself.eventually.be.rejectedWith();
})));

it("should not change char or varchar column types to nchar or nvarchar", () => Promise.all(connections.map(async connection => {
const repo = connection.getRepository(Example);

Expand Down

0 comments on commit 8683211

Please sign in to comment.