mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
101 lines
3.3 KiB
Lua
101 lines
3.3 KiB
Lua
local Declare = require 'utils.test.declare'
|
|
local EventFactory = require 'utils.test.event_factory'
|
|
local Assert = require 'utils.test.assert'
|
|
local Helper = require 'utils.test.helper'
|
|
|
|
local main_inventory = defines.inventory.character_main
|
|
local config = global.config.landfill_remover
|
|
|
|
Declare.module(
|
|
'landfill remover',
|
|
function()
|
|
local teardown
|
|
|
|
Declare.module_startup(
|
|
function(context)
|
|
teardown = Helper.startup_test_surface(context)
|
|
end
|
|
)
|
|
|
|
Declare.module_teardown(
|
|
function()
|
|
teardown()
|
|
end
|
|
)
|
|
|
|
Declare.test(
|
|
'can remove landfill',
|
|
function(context)
|
|
-- Arrange
|
|
local player = context.player
|
|
local surface = player.surface
|
|
local position = {2, 2}
|
|
|
|
surface.set_tiles({{name = 'landfill', position = position}})
|
|
|
|
local inventory = player.get_inventory(main_inventory)
|
|
inventory.clear()
|
|
inventory.insert('deconstruction-planner')
|
|
local stack = inventory.find_item_stack('deconstruction-planner')
|
|
stack.set_tile_filter(1, 'landfill')
|
|
|
|
local cursor = player.cursor_stack
|
|
cursor.set_stack(stack)
|
|
|
|
local area = {{2.1, 2.1}, {2.9, 2.9}}
|
|
|
|
-- Act
|
|
EventFactory.do_player_deconstruct_area(cursor, player, area)
|
|
inventory.clear()
|
|
|
|
-- Assert
|
|
local tile = surface.get_tile(position[1], position[2])
|
|
Assert.equal(config.revert_tile, tile.name)
|
|
end
|
|
)
|
|
|
|
local items = {
|
|
'stone-brick',
|
|
'concrete',
|
|
'hazard-concrete',
|
|
'refined-concrete',
|
|
'refined-hazard-concrete'
|
|
}
|
|
for _, item_name in pairs(items) do
|
|
Declare.test(
|
|
'can remove landfill when covered by ' .. item_name,
|
|
function(context)
|
|
-- Arrange
|
|
local player = context.player
|
|
local surface = player.surface
|
|
local position = {2, 2}
|
|
surface.set_tiles({{name = 'landfill', position = position}})
|
|
|
|
local cursor = player.cursor_stack
|
|
cursor.set_stack(item_name)
|
|
player.build_from_cursor({position = position, terrain_building_size = 1})
|
|
|
|
local inventory = player.get_inventory(main_inventory)
|
|
inventory.clear()
|
|
|
|
inventory.insert('deconstruction-planner')
|
|
local stack = inventory.find_item_stack('deconstruction-planner')
|
|
stack.set_tile_filter(1, 'landfill')
|
|
|
|
cursor.set_stack(stack)
|
|
|
|
local area = {{2.1, 2.1}, {2.9, 2.9}}
|
|
|
|
-- Act
|
|
EventFactory.do_player_deconstruct_area(cursor, player, area)
|
|
inventory.clear()
|
|
|
|
-- Assert
|
|
local tile = surface.get_tile(position[1], position[2])
|
|
Assert.equal(config.revert_tile, tile.name)
|
|
end
|
|
)
|
|
end
|
|
end
|
|
)
|