|
1 | 1 | -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/config.js
|
2 |
| -return function() |
3 |
| - local Packages = script.Parent.Parent.Parent |
4 | 2 |
|
5 |
| - local JestGlobals = require(Packages.JestGlobals) |
6 |
| - local jestExpect = JestGlobals.expect |
| 3 | +local Packages = script.Parent.Parent.Parent |
7 | 4 |
|
8 |
| - local configModule = require(script.Parent.Parent.config) |
9 |
| - local configure = configModule.configure |
10 |
| - local getConfig = configModule.getConfig |
| 5 | +local JestGlobals = require(Packages.JestGlobals) |
| 6 | +local expect = JestGlobals.expect |
| 7 | +local test = JestGlobals.test |
| 8 | +local describe = JestGlobals.describe |
| 9 | +local beforeEach = JestGlobals.beforeEach |
| 10 | +local afterEach = JestGlobals.afterEach |
11 | 11 |
|
12 |
| - describe("configuration API", function() |
13 |
| - local originalConfig |
14 |
| - beforeEach(function() |
15 |
| - -- Grab the existing configuration so we can restore |
16 |
| - -- it at the end of the test |
17 |
| - configure(function(existingConfig) |
18 |
| - originalConfig = existingConfig -- Don't change the existing config |
19 |
| - return {} |
20 |
| - end) |
| 12 | +local configModule = require(script.Parent.Parent.config) |
| 13 | +local configure = configModule.configure |
| 14 | +local getConfig = configModule.getConfig |
| 15 | + |
| 16 | +describe("configuration API", function() |
| 17 | + local originalConfig |
| 18 | + beforeEach(function() |
| 19 | + -- Grab the existing configuration so we can restore |
| 20 | + -- it at the end of the test |
| 21 | + configure(function(existingConfig) |
| 22 | + originalConfig = existingConfig -- Don't change the existing config |
| 23 | + return {} |
21 | 24 | end)
|
22 |
| - afterEach(function() |
23 |
| - configure(originalConfig) |
| 25 | + end) |
| 26 | + afterEach(function() |
| 27 | + configure(originalConfig) |
| 28 | + end) |
| 29 | + beforeEach(function() |
| 30 | + configure({ other = 123 }) |
| 31 | + end) |
| 32 | + describe("getConfig", function() |
| 33 | + test("returns existing configuration", function() |
| 34 | + local conf = getConfig() |
| 35 | + expect(conf.testIdAttribute).toEqual("data-testid") |
24 | 36 | end)
|
25 |
| - beforeEach(function() |
26 |
| - configure({ other = 123 }) |
| 37 | + end) |
| 38 | + describe("configure", function() |
| 39 | + test("merges a delta rather than replacing the whole config", function() |
| 40 | + local conf = getConfig() |
| 41 | + expect(conf).toMatchObject({ testIdAttribute = "data-testid" }) |
27 | 42 | end)
|
28 |
| - describe("getConfig", function() |
29 |
| - it("returns existing configuration", function() |
30 |
| - local conf = getConfig() |
31 |
| - jestExpect(conf.testIdAttribute).toEqual("data-testid") |
32 |
| - end) |
| 43 | + test("overrides existing values", function() |
| 44 | + configure({ testIdAttribute = "new-id" }) |
| 45 | + local conf = getConfig() |
| 46 | + expect(conf.testIdAttribute).toEqual("new-id") |
33 | 47 | end)
|
34 |
| - describe("configure", function() |
35 |
| - it("merges a delta rather than replacing the whole config", function() |
36 |
| - local conf = getConfig() |
37 |
| - jestExpect(conf).toMatchObject({ testIdAttribute = "data-testid" }) |
38 |
| - end) |
39 |
| - it("overrides existing values", function() |
40 |
| - configure({ testIdAttribute = "new-id" }) |
41 |
| - local conf = getConfig() |
42 |
| - jestExpect(conf.testIdAttribute).toEqual("new-id") |
43 |
| - end) |
44 |
| - it("passes existing config out to config function", function() |
45 |
| - -- Create a new config key based on the value of an existing one |
46 |
| - configure(function(existingConfig) |
47 |
| - return { |
48 |
| - testIdAttribute = ("%s-derived"):format(tostring(existingConfig.testIdAttribute)), |
49 |
| - } |
50 |
| - end) |
51 |
| - local conf = getConfig() -- The new value should be there, and existing values should be |
52 |
| - -- untouched |
53 |
| - jestExpect(conf).toMatchObject({ testIdAttribute = "data-testid-derived" }) |
| 48 | + test("passes existing config out to config function", function() |
| 49 | + -- Create a new config key based on the value of an existing one |
| 50 | + configure(function(existingConfig) |
| 51 | + return { |
| 52 | + testIdAttribute = ("%s-derived"):format(tostring(existingConfig.testIdAttribute)), |
| 53 | + } |
54 | 54 | end)
|
| 55 | + local conf = getConfig() -- The new value should be there, and existing values should be |
| 56 | + -- untouched |
| 57 | + expect(conf).toMatchObject({ testIdAttribute = "data-testid-derived" }) |
55 | 58 | end)
|
56 | 59 | end)
|
57 |
| -end |
| 60 | +end) |
| 61 | + |
| 62 | +return {} |
0 commit comments