Commit Graph

44 Commits

Author SHA1 Message Date
Christopher Allen
16b6d4526a refactor: Rename Blockly.Blocks, migrate to named exports (#5515)
* Rename Blockly.Blocks to Blockly.blocks
  Because it does not export a type as its default export.

  Part of #5073.

* Name default export of Blockly.blocks Blocks.

  Use named exports in Blockly.blocks by giving the former default
  export the name Blocks.

  Part of #5153.

* Reexport Blockly.blocks from blockly.js

* Document the format of renamings.js better.
2021-09-24 19:12:03 +01:00
kozbial
5f72a61b2d Remove unecessary deprecation warnings stubs 2021-09-23 12:31:55 -07:00
Aaron Dodson
66e6b6218a Make several exported private fields/methods TEST_ONLY (#5479) 2021-09-21 08:13:38 -07:00
Beka Westberg
91922aa571 Add throwing exceptions during deserialization (#5200)
* Add exception definitions

* Add tests for throwing errors during deserialization

* Add actually throwing exceptions

* Cleanup

* Cleanup

* Fix tests

* fix: PR Comments
2021-09-20 13:08:35 -07:00
alschmiedt
5b1586ee1b test: update mocha tests to use goog_module (#5440)
* Use goog.module in mocha tests

* Fix compiler warnings

* Make test helpers a module

* Name test modules Blockly.test.*

This is to be more consistent with how non-test modules are named.

Also remove top-level goog.require of TestHelpers (now
Blockly.test.helpers) since requiring a side-effect-less module does
nothing.

* Convert block_test.js and comment_test.js to goog.module syntax

* Address PR comments

* Goog modulify tests

* Goog modulify toolbox helpers

* Fixes imports and moves common tests from workspace_test.js to a helper file.

* Update test deps after rebase

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
2021-09-16 13:00:38 -07:00
jschanker
de1b3214be Enforce connection preconditions for setParent (#4999)
* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per #4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).

* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Error now thrown when calling `a.setParent(null)` if a is connected to a superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per #4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).

* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per google#4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).
* Fixed lint errors.

* Fix error conditions for setParent google#4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per google#4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).
* Fixed lint errors.
* Adjusted comment.

* Removed unnecessary set to null/added tests

* One is failing (commented out), will investigate later

* Lint fix

* Removed failing test that correctly fails

* Update comments to conform to style guide

Capitalize first letter, period at end
2021-07-13 13:56:42 -07:00
Monica Kozbial
2c83652733 Add missing whitespace to test files (#5031)
* Add missing spaces

* undo incorrect replaces in utils tests
2021-07-12 15:11:33 -07:00
jschanker
672574b056 Require field name to be string, test changes
* Now throws error for getField/getFieldValue/setFieldValue if provided name is not a string
* Changed error to more specific TypeError
* Type checking and error message moved up to getField
* Tests added/modified to check that non-string types for field names produce type errors
2021-06-16 10:46:05 +01:00
jschanker
f9c5260fb0 Added tests/setFieldValue error message
* Added tests for getting/setting field (values) when names are not supplied and test for getting a field value, setting it to a new value, and getting it again.
* Added more user-friendly error message for setFieldValue telling the developer that he/she is missing the name rather than Field "undefined" not found.
2021-06-16 10:46:05 +01:00
Neil Fraser
96315ad449 Fix removal of spaces near parens inside strings
Extra spaces should only be stripped from the inside of paren tokens.  Parens in strings (and other static content) should not be edited.
2021-06-09 22:16:35 -07:00
alschmiedt
fe0f401977 Fix collapsing bug and add tests (#4568) 2021-01-11 09:05:59 -08:00
Monica Kozbial
76fabc91f7 Capture deprecation warnings in tests that have associated bugs (#4314) 2020-09-29 09:57:17 -07:00
Maribeth Bottorff
6017a953d1 Fix bugs related to events firing during block create (#4278)
Fix bugs related to events firing during block create and add test for expected block init behavior
2020-09-15 20:02:07 -07:00
Monica Kozbial
896c630a89 Shared global cleanup (#4217)
* Refactor block type cleanup into shared cleanup.

* Use shared cleanup for block type cleanup.

* Remove overwriting of core Blockly block in test.

* Rename cleanup arrays for clarity

* Add blocks to cleanup array when defined in shared helpers

* Refactor logic for adding to shared cleanup.

* Add helper for defining block and adding block type to cleanup.

* Fix jsdocs

* Simplifying helpers for adding to cleanup.

* Add missing semicolons

* Update jsdoc for sharedTestSetup

* Use stub to wrap cleanup with defineBlocksWithJsonArray

* Remove unused helper from lint ignore
2020-09-09 15:51:34 -07:00
Monica Kozbial
afd10cb3a2 Fix workspace cleanup in tests. (#4169) 2020-08-19 15:40:12 -07:00
Rachel Fenichel
ecb8739c5f Lint 2020-08-06 10:30:04 -07:00
Rachel Fenichel
3a7a636d28 Move createRenderedBlock to test helpers, fix setup, use helper in more places 2020-08-05 20:33:34 -07:00
Rachel Fenichel
6dd5428e5b Add and use helper functions in block_test.js 2020-08-05 19:58:23 -07:00
Monica Kozbial
2e92123314 Adding async cleanup to tests (#4103)
* Adding setup and teardown to more mocha tests.

* Update workspace dispose cleanup calls.
2020-08-05 16:00:00 -07:00
Monica Kozbial
b7305c1eed Shared events cleanup (#4092)
* Remove temp fix for event queue cleanup.

* Implementing shared setup and cleanup.

* Remove unecessary restore and add comment.

* Adds helper for workspace teardown

* Remove unecessary restore calls in event tests
2020-08-03 16:50:23 -07:00
Sam El-Husseini
dc912c63ad Fix mocha tests 2020-06-04 18:10:40 -07:00
Sam El-Husseini
a5a3b045d3 Use the Blockly AST for block toString (#3895)
* Use the AST tree to populate block toString, add paranthesis around Number and Boolean connections
2020-05-14 17:06:35 -07:00
Monica Kozbial
abd6a53ac2 Add missing cleanup for block types. (#3890)
* Add missing cleanup for block types.

* Add missing dispose and remove unecessary delete.
2020-05-06 17:49:22 -07:00
Monica Kozbial
0adf7efd5f Converting jsunit asserts to chai. (#3831)
* Converting jsunit asserts to chai.

* Move jsunit functions to test_utilities.

* Adding eslint exception for helper method.
2020-04-17 16:08:46 -07:00
Beka Westberg
9e98df9949 Fix collapsed blocks not updating when modified (#3806)
* Stop recursive render calls

* Fix visibility bugs.

* Make toString ignore collapsed input.

* Add automatic collapse rendering handling

* Fix insertion markers with collapsed

* Add tests

* Fix build?

* PR comments

* Add missing jsdoc
2020-04-16 13:02:05 -07:00
Monica Kozbial
d35b3659c8 Removed duplicate block tests and renamed tests. (#3812)
* Removed duplicate block tests and renamed tests.

* Refactor shared code and add comment about parent/middle/child.
2020-04-13 15:52:44 -07:00
Neil Fraser
4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00
Sam El-Husseini
fdc50f2cd0 Add the theme name to the injection div (#3413)
* Set the theme name as a class on the injection div.
2019-11-07 15:19:58 -08:00
Rachel Fenichel
207e0ebe7b Add tests and better validation for block styles 2019-10-30 17:24:03 -07:00
Beka Westberg
c32c835088 Fixed programmatically added connections not being added to the connection db (#3318)
* Fixed programmatically added connections not getting added to the connection db.
2019-10-29 15:31:40 -07:00
Neil Fraser
b46a4fe286 Bring our license format up to date (#3127)
* Google changed from an Inc to an LLC.

This happened back in 2017 but we didn’t notice.  Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade.

* Remove project description/titles from licenses

This is no longer part of Google’s header requirements.  Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”).

* License no longer requires URL.

* Fix license regexps.
2019-10-02 14:46:56 -07:00
Beka Westberg
d5e9e4c3b4 Removed TODO. 2019-09-27 16:38:37 -07:00
Beka Westberg
1baf7d1dcf Added a bunch of connection related tests. 2019-09-27 15:56:29 -07:00
Monica Kozbial
e1e9513e86 Disconnect child block always for block.dispose(/* healStack */ true) (#3073)
* Disconnecting child block even if it cannot be connected to parent block.

* Bump disconnected child block.

* Added method for behavior on failed connection and updated expected behavior of unplug in unit tests.

* Removing obsolete TODO and calling new helper method in tests.
2019-09-25 10:47:29 -07:00
Beka Westberg
9e5df6216a Fixed comment ownership. (#2923)
* Moved comment icons to use a model-based system. The block holds the model of the comment, and the comment icon holds a reference to it.
* Reorganized the setVisible function.
* Changed how xml.js serializes and deserializes comments.
2019-09-20 13:16:07 -07:00
Beka Westberg
654467e9ac Added disposed = false properties to fields, connections, and blocks. Changed applicable unit tests from isNotOk -> isFalse. 2019-08-07 07:17:41 -07:00
Beka Westberg
56f424d8ed Added removeInput tests. 2019-08-07 07:07:30 -07:00
Beka Westberg
2f88a40f9b Added block disposal tests. 2019-08-07 07:07:30 -07:00
Beka Westberg
995a2658fe Added shadow unplug tests. 2019-08-07 07:07:30 -07:00
Beka Westberg
b28788fad6 Added licenses to tests and changed some formatting. 2019-08-07 07:07:30 -07:00
Rachel Fenichel
99dc9bb38f Fix test (matching fix in jsunit tests) 2019-05-01 14:19:55 -07:00
Rachel Fenichel
089c30baa1 Add eslintrc to mocha directory 2019-01-09 13:31:07 -08:00
Rachel Fenichel
298b93c025 Fix eslint errors with in-file comments 2019-01-08 11:54:57 -08:00
Rachel Fenichel
e27f58ada7 Add jsunit->chai assert converters, and block tests 2019-01-08 11:30:54 -08:00