|
1 | | -import { ProfanityEngine } from "../index.js"; |
| 1 | +import { ProfanityEngine } from '../index.js'; |
2 | 2 |
|
3 | | -const language = process.env.LANGUAGE || "en"; // Default to 'en' if the LANGUAGE environment variable is not set |
| 3 | +const language = process.env.LANGUAGE || 'en'; // Default to 'en' if the LANGUAGE environment variable is not set |
4 | 4 | let profanity; |
5 | 5 |
|
6 | | -describe("ProfanityEngine Functions tests", () => { |
| 6 | +describe('ProfanityEngine Functions tests', () => { |
7 | 7 | beforeAll(async () => { |
8 | 8 | profanity = new ProfanityEngine({ |
9 | | - language: "en", |
| 9 | + language: 'en', |
10 | 10 | testMode: true, |
11 | 11 | }); |
12 | 12 | await profanity.initialize(); // Initialize the profanity instance with the English language |
13 | 13 | }); |
14 | 14 |
|
15 | | - it("Should get the correct language file path", async () => { |
16 | | - const filePath = await profanity.getLanguageFilePath("es"); |
17 | | - expect(filePath).toContain("es.txt"); |
| 15 | + it('Should get the correct language file path', async () => { |
| 16 | + const filePath = await profanity.getLanguageFilePath('es'); |
| 17 | + expect(filePath).toContain('es.txt'); |
18 | 18 | }); |
19 | 19 |
|
20 | | - it("Should return the default language file path for unknown language", async () => { |
21 | | - const filePath = await profanity.getLanguageFilePath("fr"); |
22 | | - expect(filePath).toContain("en.txt"); |
| 20 | + it('Should return the default language file path for unknown language', async () => { |
| 21 | + const filePath = await profanity.getLanguageFilePath('fr'); |
| 22 | + expect(filePath).toContain('en.txt'); |
23 | 23 | }); |
24 | 24 |
|
25 | | - it("Should check if a file exists and return true", async () => { |
26 | | - const filePath = await profanity.getLanguageFilePath("en"); |
| 25 | + it('Should check if a file exists and return true', async () => { |
| 26 | + const filePath = await profanity.getLanguageFilePath('en'); |
27 | 27 | const fileExists = await profanity.fileExists(filePath); |
28 | 28 | expect(fileExists).toEqual(true); |
29 | 29 | }); |
30 | 30 |
|
31 | | - it("Should check if a file exists and return false", async () => { |
32 | | - const filePath = "nonexistent.txt"; // Assume the file doesn't exist |
| 31 | + it('Should check if a file exists and return false', async () => { |
| 32 | + const filePath = 'nonexistent.txt'; // Assume the file doesn't exist |
33 | 33 | const fileExists = await profanity.fileExists(filePath); |
34 | 34 | expect(fileExists).toEqual(false); |
35 | 35 | }); |
36 | 36 |
|
37 | | - it("Should read and split the file content correctly", async () => { |
38 | | - const filePath = await profanity.getLanguageFilePath("en"); |
| 37 | + it('Should read and split the file content correctly', async () => { |
| 38 | + const filePath = await profanity.getLanguageFilePath('en'); |
39 | 39 | const terms = await profanity.readFileAndSplit(filePath); |
40 | 40 | expect(terms.length).toBeGreaterThan(0); |
41 | 41 | }); |
42 | 42 |
|
43 | | - it("Should handle read error and set terms to the english terms", async () => { |
44 | | - const filePath = "nonexistent.txt"; // Assume the file doesn't exist |
| 43 | + it('Should handle read error and set terms to the english terms', async () => { |
| 44 | + const filePath = 'nonexistent.txt'; // Assume the file doesn't exist |
45 | 45 | await profanity.readFileAndSplit(filePath); |
46 | 46 | let terms = await profanity.all(); |
47 | 47 | expect(terms.length).toEqual(959); |
|
0 commit comments